package com.yl.core;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;

import com.yl.dao.UserDAO;
import com.yl.model.User;

/**
 * User: Dream.YnagLong Date: 13-12-12 Time: 下午8:21
 */
public class UserService {
	private UserDAO userDAO;

	/**
	 * 获取用户列表
	 * 
	 * @param user
	 * @return
	 */
	@Cacheable(value="com.yl.dao.UserDAO")
	public List<User> getUsers(User user) {
		if (user != null)
			return userDAO.getUsers(user);
		return userDAO.getUsers();
	}

	/**
	 * 用户登陆
	 * 
	 * @param user
	 * @return
	 */
	public User login(User user) {
		return userDAO.getUserByCondition(user);
	}

	/**
	 * 用户注册
	 * 
	 * @param user
	 * @return
	 */
	public int register(User user) {
		return userDAO.insertUser(user);
	}

	/**
	 * 用户更新
	 * 
	 * @param user
	 *
	 *TriggersRemove(cacheName="com.yl.dao.UserDAO",removeAll=true) 
	 */
	public void updateUser(User user) {
		userDAO.updateUser(user);
	}

	public UserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

}
